
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.ArrayList;
import java.io.IOException;
import java.io.DataInputStream;
import javax.swing.*;

import javax.swing.JApplet;

public class test extends JApplet {
	JLabel nameLabel = new JLabel("Name");
	JTextField nameValue = new JTextField();
	
	JLabel rollNumber = new JLabel("Roll Number");
	JTextField rollText = new JTextField();
	
	JCheckBox SEc = new JCheckBox("Software Engineering");
	JCheckBox FSc = new JCheckBox("Foundations of Security");
	JCheckBox DMc = new JCheckBox("Data Mining");
	JCheckBox FINc = new JCheckBox("Introduction to Finance");
	JCheckBox IAc = new JCheckBox("Image Analysis");
	JCheckBox DHDc = new JCheckBox("Digital Hardware Design");
	JCheckBox MLc = new JCheckBox("Machine Learning");
	JCheckBox SCc = new JCheckBox("Secure Coding");
	JCheckBox DBSIc = new JCheckBox("Database Systems Implementation");
	JCheckBox CAc = new JCheckBox("Computer Architecture");
	JCheckBox LCSc = new JCheckBox("Logic For Computer Science");
	JCheckBox RAc = new JCheckBox("Randomized Algorithms");
	JCheckBox ACc = new JCheckBox("Applied Cryptography");
	JCheckBox IGDMc = new JCheckBox("Introduction to GeoSpatial Data Management");
	JCheckBox MCNSc = new JCheckBox("Mobile and Cellular Network Security");
	JCheckBox ADFTYc = new JCheckBox("Application Development For Facebook, Twitter and Youtube");
	JCheckBox PHYc = new JCheckBox("Physics");
	JCheckBox BTc = new JCheckBox("Biotechnology");
	JCheckBox ECc = new JCheckBox("Entrepreneurship as Career");
	
	JLabel L1 = new JLabel("first Recommendation");
	JLabel L2 = new JLabel("second Recommendation");
	JLabel L3 = new JLabel("third Recommendation");
	JLabel L4 = new JLabel("fourth Recommendation");
	JLabel R1 = new JLabel("fifth Recommendation");
	JLabel R2 = new JLabel("sixth Recommendation");
	JLabel R3 = new JLabel("seventh Recommendation");
	JLabel R4 = new JLabel("eighth Recommendation");
	
	JLabel team = new JLabel("TEAM : Crusaders");
	JLabel ad = new JLabel("Akashdeep (2009008)");
	JLabel nm = new JLabel("Nikhil Mahajan (2009029)");
	JLabel ps = new JLabel("Prashant Singh (2009033)");
	
	JButton start = new JButton("START");
	
	public static JFrame f2 = new JFrame("DATA GENERATOR");
	
	public static JPanel JP2 = new JPanel();
	
	public static JCheckBox P1 = new JCheckBox("Pre-Requisite 1");
	public static JCheckBox P2 = new JCheckBox("Pre-Requisite 2");
	public static JCheckBox P3 = new JCheckBox("Pre-Requisite 3");
	public static JCheckBox P4 = new JCheckBox("Pre-Requisite 4");
	public static JCheckBox P5 = new JCheckBox("Pre-Requisite 5");
	public static JCheckBox P6 = new JCheckBox("Pre-Requisite 6");
	public static JCheckBox P7 = new JCheckBox("Pre-Requisite 7");
	public static JCheckBox P8 = new JCheckBox("Pre-Requisite 8");
	
	public static JLabel nameL = new JLabel("Name :");
	public static JLabel rollL = new JLabel("Roll Number :");
	public static JLabel pc = new JLabel("Previous Course ");
	public static JLabel pc1 = new JLabel("Previous Course ");
	public static JLabel grade = new JLabel("Grade");
	public static JLabel grade1 = new JLabel("Grade");
	
	public static JTextField name = new JTextField();
	public static JTextField roll = new JTextField();
	public static JTextField T1 = new JTextField();
	public static JTextField T2 = new JTextField();
	public static JTextField T3 = new JTextField();
	public static JTextField T4 = new JTextField();
	public static JTextField T5 = new JTextField();
	public static JTextField T6 = new JTextField();
	public static JTextField T7 = new JTextField();
	public static JTextField T8 = new JTextField();
	
	public static ArrayList<String> course = new ArrayList<String>();
	public static ArrayList<String> Grade = new ArrayList<String>();
	
	public static JButton JB1 = new JButton("SUBMIT");
	
	JFrame f = new JFrame("2ndForm");
	
	
	JButton add = new JButton("Add");
	JButton remove = new JButton("Remove");
	JButton clear = new JButton("Clear");
	JButton Submit = new JButton("Submit");
	JButton Submit1 = new JButton("Submit");
	
	String subject[] = {"Software Engineering", "Foundations of Security", "Data Mining","Introduction to Finance", "Image Analysis", "Digital Hardware Design","Machine Learning", "Secure Coding", "Database Systems Implementation", "Computer Architecture","Logic For Computer Science", "Randomized Algorithms", "Applied Cryptography", "Introduction to GeoSpatial Data Management","Mobile and Cellular Network Security", "Application Development For Facebook, Twitter and Youtube", "Physics", "Biotechnology","Entrepreneurship as Career"};
	
	ArrayList<String> arr = new ArrayList<String>();
	ArrayList<String> Subs = new ArrayList<String>();
	
	JPanel JP = new JPanel();
	DefaultListModel listModel2 = new DefaultListModel();
	
	JList list = new JList(listModel2);
	JScrollPane SP = new JScrollPane(list);
	DefaultListModel listModel = new DefaultListModel();
	JList list1 = new JList(listModel);
	
	ImageIcon image = new ImageIcon("C:\\Users\\Sony\\Documents\\Softwares\\eclipse\\Applet\\bin\\CourseVillaPro.jpg");
	JLabel JP3 = new JLabel(image);
	
	public void init() {
		
	this.setSize(1360, 768);
	setLayout(null);
	setBackground(Color.black);
	initializeScreen();
	//GUI1();
		
	}
	
	public void Paint(Graphics g){
		setBackground(Color.black);
	}
	
	
	public void initializeScreen(){
		add(JP3);
		JP3.reshape(0, 0, 1100, 700);
		JP3.setVisible(true);
		
		add(team);
		team.reshape(1100, 200, 200, 30);
		team.setVisible(true);
		team.setForeground(Color.red);
		team.setFont(new Font("Dialog",1,20));
		
		add(ad);
		ad.reshape(1100, 250, 200, 30);
		ad.setVisible(true);
		ad.setForeground(Color.blue.darker());
		ad.setFont(new Font("Dialog",2,15));
		
		add(nm);
		nm.reshape(1100, 270, 200, 30);
		nm.setVisible(true);
		nm.setForeground(Color.blue.darker());
		nm.setFont(new Font("Dialog",2,15));
		
		add(ps);
		ps.reshape(1100, 290, 200, 30);
		ps.setVisible(true);
		ps.setForeground(Color.blue.darker());
		ps.setFont(new Font("Dialog",2,15));
		
		add(start);
		start.reshape(1130, 340, 100, 30);
		start.setVisible(true);
		start.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e){
				GUI1();
			}
		});
	}
	
	public void GUI2(){
		add(nameLabel);
		nameLabel.reshape(280,50,100,25);
		
		add(nameValue);
		nameValue.reshape(390,50,100,25);
		
		add(rollNumber);
		rollNumber.reshape(280,90,100,25);
		
		add(rollText);
		rollText.reshape(390,90,100,25);
		
		add(JP);
		JP.reshape(50, 120, 800, 400);
		JP.setLayout(null);
		
		JP.add(SEc);
		SEc.reshape(50, 50, 200, 25);
		
		JP.add(FSc);
		FSc.reshape(50, 80, 200, 25);
		
		JP.add(DMc);
		DMc.reshape(50, 110, 200, 25);
		
		JP.add(FINc);
		FINc.reshape(50, 140, 200, 25);
		
		JP.add(IAc);
		IAc.reshape(50, 170, 200, 25);
		
		JP.add(DHDc);
		DHDc.reshape(50, 200, 200, 25);
		
		JP.add(MLc);
		MLc.reshape(250, 50, 200, 25);
		
		JP.add(SCc);
		SCc.reshape(250, 80, 200, 25);
		
		JP.add(DBSIc);
		DBSIc.reshape(250, 110, 200, 25);
		
		JP.add(CAc);
		CAc.reshape(250, 140, 200, 25);
		
		JP.add(LCSc);
		LCSc.reshape(250, 170, 200, 25);
		
		JP.add(RAc);
		RAc.reshape(250, 200, 200, 25);
		
		JP.add(ACc);
		ACc.reshape(250, 230, 200, 25);
		
		JP.add(IGDMc);
		IGDMc.reshape(450, 50, 200, 25);
		
		JP.add(MCNSc);
		MCNSc.reshape(450, 80, 200, 25);
		
		JP.add(ADFTYc);
		ADFTYc.reshape(450, 110, 200, 25);
		
		JP.add(PHYc);
		PHYc.reshape(450, 140, 200, 25);
		
		JP.add(BTc);
		BTc.reshape(450, 170, 200, 25);
		
		JP.add(ECc);
		ECc.reshape(450, 200, 200, 25);
		
		JP.add(Submit);
		Submit.reshape(270, 280, 100, 25);
		Submit.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e){
				if(SEc.isSelected()){
					Subs.add(SEc.getText());
				}
				if(FSc.isSelected()){
					Subs.add(FSc.getText());
				}
				if(DMc.isSelected()){
					Subs.add(DMc.getText());
				}
				if(FINc.isSelected()){
					Subs.add(FINc.getText());
				}
				if(IAc.isSelected()){
					Subs.add(IAc.getText());
				}
				if(DHDc.isSelected()){
					Subs.add(DHDc.getText());
				}
				if(MLc.isSelected()){
					Subs.add(MLc.getText());
				}
				if(SCc.isSelected()){
					Subs.add(SCc.getText());
				}
				if(DBSIc.isSelected()){
					Subs.add(DBSIc.getText());
				}
				if(CAc.isSelected()){
					Subs.add(CAc.getText());
				}
				if(LCSc.isSelected()){
					Subs.add(LCSc.getText());
				}
				if(RAc.isSelected()){
					Subs.add(RAc.getText());
				}
				if(ACc.isSelected()){
					Subs.add(ACc.getText());
				}
				if(IGDMc.isSelected()){
					Subs.add(IGDMc.getText());
				}
				if(MCNSc.isSelected()){
					Subs.add(MCNSc.getText());
				}
				if(ADFTYc.isSelected()){
					Subs.add(ADFTYc.getText());
				}
				if(PHYc.isSelected()){
					Subs.add(PHYc.getText());
				}
				if(BTc.isSelected()){
					Subs.add(BTc.getText());
				}
				if(ECc.isSelected()){
					Subs.add(ECc.getText());
				}
				
				String subjects [] = new String[Subs.size()];
				
				for(int i = 0; i < Subs.size(); i++){
					subjects[i]= Subs.get(i);
				}
				/*
				System.out.println(nameValue.getText());
				System.out.println(rollText.getText());
				
				for(int i = 0; i < subjects.length; i++){
					System.out.println(subjects[i]);
				}
				
				*/
				clear();
				System.out.println("Chu saali");
				secondForm();
			}
		});
	}
	
	public void clear() 
	{ 
	//setLayout(null);
	
	JP.setVisible(false);
	
	nameValue.disable();
	rollText.disable();
	
	Graphics g = this.getGraphics(); 

	Dimension d = this.getSize(); 

	g.fillRect(0,0,d.width,d.height); 

	repaint(); 
	}
	
	public void secondForm()
	{
		//setLayout(null);
		for(int i = 0; i < subject.length; i++){
			listModel2.add(i, subject[i]);
		}
		
		add(list);
		add(SP);
		
		list.setLocation(120, 300);
		SP.setLocation(120, 300);
		SP.reshape(120, 300, 200, 200);
		SP.getViewport().add(list);
		list.setVisible(true);
		
		this.getContentPane().add(list1);
		list1.reshape(500, 300, 200, 200);
		list1.setVisible(true);
		
		add(L1);
		L1.reshape(170, 150, 200, 30);
		L1.setVisible(true);
		
		add(L2);
		L2.reshape(170, 180, 200, 30);
		L2.setVisible(true);
		
		add(L3);
		L3.reshape(170, 210, 200, 30);
		L3.setVisible(true);
		
		add(L4);
		L4.reshape(170, 240, 200, 30);
		L4.setVisible(true);
		
		add(R1);
		R1.reshape(530, 150, 200, 30);
		R1.setVisible(true);
		
		add(R2);
		R2.reshape(530, 180, 200, 30);
		R2.setVisible(true);
		
		add(R3);
		R3.reshape(530, 210, 200, 30);
		R3.setVisible(true);
		
		add(R4);
		R4.reshape(530, 240, 200, 30);
		R4.setVisible(true);
		
		add(add);
		add.reshape(360,340,100,25);
		add.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent e){
			if(list.getSelectedIndex() != -1){
				listModel.addElement(list.getSelectedValue());
				listModel2.remove(list.getSelectedIndex());
				list1.show();
				list.show();
			}
		}
	});
	
	add(remove);
	remove.reshape(360,390,100,25);
	remove.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e){
			if(list1.getSelectedIndex() != -1){
				listModel2.add(listModel2.size()-1, list1.getSelectedValue());
				listModel.remove(list1.getSelectedIndex());
				list1.setSelectedIndex(list1.getLastVisibleIndex());
			}
			else{
				listModel2.add(listModel2.getSize()-1, listModel.elementAt(listModel.size()-1));
				@SuppressWarnings("deprecation")
				int pos = list1.getLastVisibleIndex();
				if (pos >= 0) {
				    listModel.remove(pos);
				    list1.setSelectedIndex(list1.getLastVisibleIndex());
				}
			}
		}
	});
	
	add(clear);
	clear.reshape(360,440,100,25);
	clear.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent e){
			listModel2.clear();
			for(int i = 0; i < subject.length; i++){
				listModel2.add(i, subject[i]);
			}
				listModel.clear();
				list1.show();
		}
	});
	
	add(Submit1);
	Submit1.reshape(360,540,100,25);
	Submit1.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent e){
			list.setVisible(false);
			list1.setVisible(false);
			SP.setVisible(false);
			L1.setVisible(false);
			L2.setVisible(false);
			L3.setVisible(false);
			L4.setVisible(false);
			R1.setVisible(false);
			R2.setVisible(false);
			R3.setVisible(false);
			R4.setVisible(false);
			add.setVisible(false);
			remove.setVisible(false);
			clear.setVisible(false);
			Submit1.setVisible(false);
			nameValue.setVisible(false);
			nameLabel.setVisible(false);
			rollNumber.setVisible(false);
			rollText.setVisible(false);
			
		}
	});

	}
	
	public void GUI1(){
		
		add(JP2);
		JP2.reshape(f2.insets().left, f2.insets().top, 699, 499);
		JP2.setVisible(true);
		
		JP2.setLayout(null);
		JP2.add(nameL);
		nameL.reshape(f2.insets().left + 240, f2.insets().top + 10, 50, 30);
		nameL.setVisible(true);
		
		JP2.add(name);
		name.reshape(f2.insets().left + 340, f2.insets().top + 10, 100, 30);
		name.setVisible(true);
		
		JP2.add(rollL);
		rollL.reshape(f2.insets().left + 240, f2.insets().top + 50, 100, 30);
		rollL.setVisible(true);
		
		JP2.add(roll);
		roll.reshape(f2.insets().left + 340, f2.insets().top + 50, 100, 30);
		roll.setVisible(true);
		
		JP2.add(pc);
		pc.reshape(f2.insets().left + 70, f2.insets().top + 100, 100, 30);
		pc.setVisible(true);
		
		JP2.add(grade);
		grade.reshape(f2.insets().left + 200, f2.insets().top + 100, 100, 30);
		grade.setVisible(true);
		
		JP2.add(pc1);
		pc1.reshape(f2.insets().left + 370, f2.insets().top + 100, 100, 30);
		pc1.setVisible(true);
		
		JP2.add(grade1);
		grade1.reshape(f2.insets().left + 500, f2.insets().top + 100, 100, 30);
		grade1.setVisible(true);
	
		JP2.add(P1);
		P1.reshape(f2.insets().left + 70, f2.insets().top + 150, 120, 30);
		P1.setVisible(true);
		
		JP2.add(T1);
		T1.reshape(f2.insets().left + 200, f2.insets().top + 150, 50, 30);
		T1.setVisible(true);
		
		JP2.add(P2);
		P2.reshape(f2.insets().left + 70, f2.insets().top + 200, 120, 30);
		P2.setVisible(true);
		
		JP2.add(T2);
		T2.reshape(f2.insets().left + 200, f2.insets().top + 200, 50, 30);
		T2.setVisible(true);
		
		JP2.add(P3);
		P3.reshape(f2.insets().left + 70, f2.insets().top + 250, 120, 30);
		P3.setVisible(true);
		
		JP2.add(T3);
		T3.reshape(f2.insets().left + 200, f2.insets().top + 250, 50, 30);
		T3.setVisible(true);
		
		JP2.add(P4);
		P4.reshape(f2.insets().left + 70, f2.insets().top + 300, 120, 30);
		P4.setVisible(true);
		
		JP2.add(T4);
		T4.reshape(f2.insets().left + 200, f2.insets().top + 300, 50, 30);
		T4.setVisible(true);
		
		JP2.add(P5);
		P5.reshape(f2.insets().left + 370, f2.insets().top + 150, 120, 30);
		P5.setVisible(true);
		
		JP2.add(T5);
		T5.reshape(f2.insets().left + 500, f2.insets().top + 150, 50, 30);
		T5.setVisible(true);
		
		JP2.add(P6);
		P6.reshape(f2.insets().left + 370, f2.insets().top + 200, 120, 30);
		P6.setVisible(true);
		
		JP2.add(T6);
		T6.reshape(f2.insets().left + 500, f2.insets().top + 200, 50, 30);
		T6.setVisible(true);
		
		JP2.add(P7);
		P7.reshape(f2.insets().left + 370, f2.insets().top + 250, 120, 30);
		P7.setVisible(true);
		
		JP2.add(T7);
		T7.reshape(f2.insets().left + 500, f2.insets().top + 250, 50, 30);
		T7.setVisible(true);
		
		JP2.add(P8);
		P8.reshape(f2.insets().left + 370, f2.insets().top + 300, 120, 30);
		P8.setVisible(true);
		
		JP2.add(T8);
		T8.reshape(f2.insets().left + 500, f2.insets().top + 300, 50, 30);
		T8.setVisible(true);
		
		JP2.add(JB1);
		JB1.reshape(f2.insets().left + 270, f2.insets().top + 350, 120, 30);
		JB1.setVisible(true);		
		JB1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e){
					
				if(P1.isSelected()){
					course.add("PQ-1");
					Grade.add(T1.getText());
				}
				
				if(P2.isSelected()){
					course.add("PQ-2");
					Grade.add(T2.getText());
				}
				if(P3.isSelected()){
					course.add("PQ-3");
					Grade.add(T3.getText());
				}
				if(P4.isSelected()){
					course.add("PQ-4");
					Grade.add(T4.getText());
				}
				if(P5.isSelected()){
					course.add("PQ-5");
					Grade.add(T5.getText());
				}
				if(P6.isSelected()){
					course.add("PQ-6");
					Grade.add(T6.getText());
				}
				if(P7.isSelected()){
					course.add("PQ-7");
					Grade.add(T7.getText());
				}
				if(P8.isSelected()){
					course.add("PQ-8");
					Grade.add(T8.getText());
				}
				for(int i = 0; i < course.size(); i++){
					System.out.println(course.get(i)+" = "+Grade.get(i));
				}
				JP2.setVisible(false);
				GUI2();
			}
		});
	}
	static public void main(String args[]) {
	    test.main(new String[] { "test" });
	}
}